import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig((mode) => {
  return {
    plugins: [
      vue(),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    resolve: {
      alias: {
        "@": resolve(__dirname, "./src"),
      },
    },
    server: {
      open: true,
      proxy: {
        "/content-url": {
          // 接口地址
          target: "https://www.aceplusdigital.com",
          changeOrigin: true,
          secure: false,
          rewrite: (path) => path.replace(/^\/content-url/, ""), // 将 /api 开头的请求路径重写为空
        },
      },
    },
  };
});
